<template>
    <div class="container">
        <!-- 顶部导航栏 -->
        <GeneralTopBar :showPosition="false"/>
        <main class="margin-20per">
            <aside>
                <ul>
                    <li v-for="menu in menuList" :key="menu.name"
                        :class="{'selected': currentMenu === menu.name}"
                        @click="menuSelect(menu.name)"
                    >
                        <SymbolIcon :icon-class="menu.icon"/>
                        <el-link  :href="menu.href">{{ menu.name }}</el-link>
                    </li>
                </ul>
            </aside>
            <div class="main-content">
                <transition name="el-fade-in">
                    <!-- 工作台 -->
                    <div class="work-table" v-if="!showResume">
                        <!-- 顶部状态信息栏 -->
                        <div class="recruiter-status">
                            <div class="status-wrapper">
                                <div class="status-title">{{ status.applicant_num }}</div>
                                <div class="status-content">候选人</div>
                            </div>
                            <div class="status-wrapper">
                                <div class="status-title">{{ status.apply_num }}</div>
                                <div class="status-content">新简历</div>
                            </div>
                            <div class="status-wrapper">
                                <div class="status-title">{{ status.job_num }}</div>
                                <div class="status-content">已发布职位</div>
                            </div>
                            <div class="status-wrapper">
                                <div class="status-title">{{ status.feedback_rate }}%</div>
                                <div class="status-content">简历反馈率</div>
                            </div>
                            <div class="status-wrapper">
                                <div class="status-title">{{ status.login_date }}</div>
                                <div class="status-content">最近登录</div>
                            </div>
                            <el-button type="primary" class="add-job-btn" @click="$router.push('/recruiter/post')">发布新职位</el-button>
                        </div>
                        <!-- 近期面试 -->
                        <div class="recent-interview">
                            <h2>
                                <span>近期面试（对方已同意请求）</span>
<!--                                <span>（共{{ recent_interview_num }}场）</span>-->
                                <el-link href="/recruiter/interview">查看更多<i class="el-icon-arrow-right"></i> </el-link>
                            </h2>
                            <div class="content" v-if="interviewList.length === 0">
                                <el-empty :image-size="200"></el-empty>
                            </div>
                            <div class="content" v-else>
                                <el-timeline>
                                    <el-timeline-item
                                            v-for="(interview) in interviewList"
                                            :key="interview.id"
                                            icon="el-icon-yuanhuan"
                                            :timestamp="interview.sendingTime"
                                            hide-timestamp
                                    >
                                        <div class="timeStamp">
                                            <div class="date">{{ splitTimeStamp(interview.sendingTime)[0] }}</div>
                                            <div class="time">{{ splitTimeStamp(interview.interviewTime)[1] }}</div>
                                        </div>
                                        <div class="interview-wrapper">
                                            <div class="applicant-avatar">
                                                <img :src="interview.userinfo.face" :alt="interview.userinfo.name"
                                                     style="width: 65px; height: 65px;"/>
<!--                                                <img :src="getImageSource" :alt="interview.userinfo.name"-->
<!--                                                     style="width: 65px; height: 65px;"/>-->
                                            </div>
                                            <div class="interview-content">
                                                <div class="applicant">
                                                    <p>
                                                        <span class="applicant-name">{{ interview.userinfo.name }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.userinfo.sex }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.userinfo.politicalOutlook }}</span>
<!--                                                        <el-button round @click="showResume = true">查看简历</el-button>-->
                                                        <el-button round @click="viewResume(interview.userinfoId)">查看简历</el-button>
                                                    </p>
                                                    <p>
                                                        <span>{{ interview.userinfo.age }}岁</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.userinfo.workExperience.title }}经验</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.userinfo.recruitmentEducation.title}}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.userinfo.city.title }}</span>
                                                    </p>
                                                    <p>
                                                        <span class="icon"><i class="el-icon-phone"></i></span>
                                                        <span>{{ interview.userinfo.tel }}</span>
                                                    </p>
                                                </div>
                                                <div class="job">
                                                    <el-link class="job-duty" href="/profession/detail"> 面试职位:{{ interview.recruitmentPost.title }}</el-link>
                                                    <p>
                                                        <span class="job-salary">{{ interview.recruitmentPost.expectedSalary.title}}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.recruitmentPost.workExperience.title }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ interview.recruitmentPost.natureWork.title }}</span>
                                                    </p>
<!--                                                                                <p v-if="interview.agree === true">已同意面试</p>-->
<!--                                                                                <p v-else-if="interview.agree === false">面试被拒绝</p>-->
                                                    <p v-if="interview.endInterview === true">面试已结束</p>
                                                    <p v-else-if="interview.endInterview === false">面试未开始</p>
                                                </div>
                                            </div>
                                        </div>
                                    </el-timeline-item>
                                </el-timeline>
                            </div>
                        </div>
                        <!-- 最新投递 -->
                        <div class="recent-apply">
                            <h2>
                                <span>最新投递</span>
                                <!--                  <span>（共{{ recent_apply_num }}份）</span>-->
                                <el-link href="/recruiter/resume">查看更多<i class="el-icon-arrow-right"></i> </el-link>
                            </h2>
                                            <div class="content" v-if="RecruitmentDelivery.length ===0">
                                              <el-empty :image-size="200"></el-empty>
                                            </div>
                            <div class="content">
                                <ul>
                                    <li v-for="(apply) in RecruitmentDelivery" :key="apply.id">
                                        <div class="apply-wrapper">
                                            <div class="applicant-avatar">
                                                <img :src="apply.userinfo.face" :alt="apply.userinfo.name"
                                                     style="width: 80px; height: 80px;"/>
                                            </div>
                                            <div class="apply-content">
                                                <div class="applicant">
                                                    <p>
                                                        <span class="applicant-name">{{ apply.userinfo.name }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.sex }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.politicalOutlook}}</span>
                                                        <el-button round @click="viewResume(apply.userinfoId)">查看简历</el-button>
                                                    </p>
                                                    <p>
                                                        <span>{{ apply.userinfo.age }}岁</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.workExperience.title }}经验</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.recruitmentEducation.title}}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{apply.userinfo.city.title }}</span>
                                                    </p>
                                                    <p v-if="apply.userinfo.state.title" class="school-name">
                                                        <span>{{ apply.userinfo.state.title }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.expectedSalary.title }}</span>
                                                    </p>
                                                    <p v-else>暂无学业信息</p>
                                                </div>
                                                <div class="job">

                                                    <el-link class="job-duty" href="/profession/detail">面试职位：{{ apply.recruitmentPost.title}}</el-link>
                                                    <p>
                                                        <span class="job-salary">{{ apply.userinfo.position.title }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.workExperience.title }}</span>
                                                        <el-divider direction="vertical"></el-divider>
                                                        <span>{{ apply.userinfo.recruitmentEducation.title }}</span>
                                                    </p>
                                                </div>
                                                <div class="apply-status">
                                                    <p>投递时间</p>
                                                    <p>{{ apply.deliveryTime }}</p>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- 简历详情 -->
                    <ShowResume v-else :applicant_id="selectedUserinfoID"/>
                </transition>
            </div>
        </main>
        <!-- 底部信息栏 -->
        <GeneralFooter />
    </div>
</template>

<script>
    import GeneralTopBar from "../../../components/GeneralTopBar";
    import GeneralFooter from "../../../components/GeneralFooter";
    import SymbolIcon from "@/components/SymbolIcon";
    import ShowResume from "../widgets/ShowResume.vue";
    export default {
        name: "Recruiter11",
        components: {ShowResume, GeneralTopBar, GeneralFooter, SymbolIcon},
        data() {
            return {
                menuList: [
                    { icon: "el-icon-gongzuotai", name: "工作台", href: "/recruiter"},
                    { icon: "el-icon-zhiwei", name: "职位管理", href: "/recruiter/job"},
                    { icon: "el-icon-jianli", name: "简历处理", href: "/recruiter/resume"},
                    { icon: "el-icon-mianshi", name: "面试相关", href: "/recruiter/interview"},
                    { icon: "el-icon-xiaoxi", name: "我的消息", href: "/recruiter/message"},
                    { icon: "el-icon-shezhi", name: "账号设置", href: "/recruiter/setting"}
                ],
                currentMenu: "工作台",

                status: {
                    applicant_num: 105,
                    apply_num: 245,
                    job_num: 45,
                    feedback_rate: "90",
                    login_date: "2天内"
                },
                interviewList: [],
                RecruitmentDelivery: [],
                showResume: false,
                selectedUserinfoID: "",
            }
        },
        created() {
            this.initData();
        },
        methods: {
            async initData() {
                let getRecruitmentDelivery = async () => {
                    const res = await this.$axios.request({
                        url: `/web/RecruitmentDelivery/LISTFIND`,
                        method: "get",
                        params:{
                            publisherId:1
                        }
                    })
                    // console.log(res);
                    if(res.data.msg === "success") {
                        this.RecruitmentDelivery=res.data.recruitmentDeliveryList;
                    }
                };
                let getInterviewList =async () => {
                    const rec=await this.$axios.request({
                        url:`/web/InterviewInvitation/listFire`,
                        method:"get",
                        params:{
                            publisherId:1
                        }
                    })
                    // console.log(rec)
                    if(rec.data.msg === "success"){
                        this.interviewList=rec.data.interviewInvitationList
                        // console.log(this.interviewList)
                    }

                }

                this.$axios.all([getRecruitmentDelivery(),getInterviewList()])
            },
            menuSelect(name) {
                this.currentMenu = name;
            },
            splitTimeStamp(timeStamp) {
                return timeStamp.split(" ");
            },
            viewResume(userinfoId) {
                this.selectedUserinfoID = userinfoId;
                this.showResume = true;
                console.log(this.selectedUserinfoID)
            }
        },
        // computed: {
        //     getImageSource() {
        //         const mimeType = "image/jpeg"; // 根据实际情况设置正确的MIME类型
        //         const dataUrl = `data:${mimeType};base64,${base64Data}`;
        //         return dataUrl;
        //     },
        // },
    }

</script>

<style lang="less" scoped>
    .el-link-active{
        transition: .3s;
        &:hover{
            color: @mainColor;
        }
        &:active{
            color: @activeColor;
        }
    }
    .el-button-active{
        transition: .3s;
        &:hover, &:focus{
            background: @mainColor;
            border: @mainColor;
            color: #fff;
        }
        &:active{
            background: @activeColor;
            border: @activeColor;
        }
    }

    @mainColor: #5dd5c8;
    @activeColor: #00c2b3;
    @background: #fff;
    @fontColor: #414a60;
    @salaryColor: #fb670f;
    @promptColor: #8d92a1;
    @borderColor: #dcdfe6;

    main {
        padding-top: 30px;
        display: flex;
        h2{
            font-size: 20px;
            position: relative;
            span{
                &:first-child{
                    color: @fontColor;
                    font-size: 20px;
                    font-weight: bold;
                }
                color: @promptColor;
                font-size: 14px;
                font-weight: normal;
            }
            .el-link{
                font-size: 15px;
                position: absolute;
                right: 0;
                top: 50%;
                transform: translateY(-50%);
                cursor: pointer;
                color: @mainColor;
                .el-link-active();
            }
        }
        .content{
            margin-top: 60px;
        }
        aside {
            background: @background;
            width: 160px;
            height: fit-content;
            margin-right: 20px;
            flex-shrink: 0;
            ul li {
                font-size: 15px;
                height: 60px;
                line-height: 60px;
                position: relative;

                &.selected {
                    &::after {
                        content: "";
                        background: @activeColor;
                        width: 2px;
                        height: 18px;
                        position: absolute;
                        left: 0;
                        top: 50%;
                        transform: translateY(-50%);
                    }

                    .el-link {
                        color: #00d7c6;
                    }
                }

                .icon {
                    font-size: 18px;
                    margin-left: 30px;
                    margin-right: 12px;
                }

                .el-link {
                    cursor: pointer;
                    color: @fontColor;
                    .el-link-active();
                }

            }
        }
        .main-content{
            min-width: 1188px;
            flex: 1;
            .work-table{
                > div{
                    padding: 20px 30px;
                    background: @background;
                    & + div{
                        margin-top: 20px;
                    }
                }
                .recruiter-status{
                    .status-wrapper{
                        display: inline-block;
                        padding: 0 30px;
                        text-align: center;
                        position: relative;
                        & + .status-wrapper::before{
                            content: "";
                            display: block;
                            width: 1px;
                            height: 25px;
                            background: @borderColor;
                            position: absolute;
                            left: 0;
                            top: 50%;
                            transform: translateY(-50%);
                        }
                        div{
                            height: 32px;
                            line-height: 32px;
                        }
                        .status-title{
                            color: @activeColor;
                            font-size: 22px;
                            font-weight: 600;
                        }
                        .status-content{
                            color: @promptColor;
                        }
                    }
                    .add-job-btn{
                        height: 54px;
                        padding: 0 45px;
                        font-size: 16px;
                        float: right;
                        transform: translateY(5px);
                    }
                }
                .recent-interview{
                    .el-timeline{
                        /deep/ .el-timeline-item{
                            margin-left: 100px;
                            padding-bottom: 28px;
                            &:last-child {
                                padding-bottom: 0;
                                .interview-wrapper{
                                    border-bottom: 0;
                                }
                            }
                            .el-timeline-item__tail{
                                border-color: @activeColor;
                            }
                            .el-timeline-item__node{
                                background: @background;
                            }
                            .el-timeline-item__icon{
                                color: @activeColor;
                            }
                        }
                        /deep/ .el-timeline-item__content {
                            color: @fontColor;
                        }
                    }
                    .timeStamp{
                        position: absolute;
                        top: -14px;
                        left: -100px;
                        text-align: right;
                        .date{
                            font-size: 18px;
                            color: @activeColor;
                        }
                        .time{
                            font-size: 15px;
                            margin-top: 2px;
                        }
                    }
                    .interview-wrapper{
                        margin-left: 25px;
                        padding-bottom: 30px;
                        border-bottom: 1px solid @borderColor;
                        position: relative;
                        bottom: 25px;
                        .applicant-avatar{
                            display: block;
                            float: left;
                        }
                        .interview-content{
                            margin-left: 80px;
                            > div{
                                display: inline-block;
                            }
                            p{
                                height: 30px;
                                line-height: 30px;
                                color: @promptColor;
                                span{
                                    &.applicant-name{
                                        color: @fontColor;
                                        font-size: 20px;
                                    }
                                    &.icon{
                                        margin-right: 8px;
                                    }
                                }
                                .el-button.is-round {
                                    float: right;
                                    .el-button-active();
                                }
                            }
                            .applicant{
                                width: 50%;
                                border-right: 3px dashed @borderColor;
                                padding-right: 25px;
                            }
                            .job{
                                margin-left: 25px;
                                .job-duty{
                                    height: 30px;
                                    line-height: 30px;
                                    font-size: 20px;
                                    color: @fontColor;
                                    .el-link-active();
                                }
                                .job-salary{
                                    font-size: 16px;
                                    color: @salaryColor;
                                }
                            }
                        }
                    }
                }
                .recent-apply{
                    ul li{
                        & + li {
                            margin-top: 30px;
                        }
                        &:last-child{
                            .apply-wrapper{
                                border-bottom: 0;
                            }
                        }
                    }
                    .apply-wrapper{
                        margin-left: 0;
                        padding-bottom: 30px;
                        border-bottom: 1px solid @borderColor;
                        position: relative;
                        .applicant-avatar{
                            display: block;
                            float: left;
                        }
                        .apply-content{
                            margin-left: 95px;
                            display: flex;
                            > div{
                                display: inline-block;
                            }
                            p{
                                padding-right: 25px;
                                height: 45px;
                                line-height: 45px;
                                color: @promptColor;
                                span{
                                    &.applicant-name{
                                        color: @fontColor;
                                        font-size: 20px;
                                    }
                                    &.icon{
                                        margin-right: 8px;
                                    }
                                }
                                .el-button.is-round {
                                    float: right;
                                    .el-button-active();
                                }
                            }
                            .applicant{
                                width: 40%;
                                border-right: 3px dashed @borderColor;
                                p{
                                    height: 30px;
                                    line-height: 30px;
                                }
                            }
                            .job{
                                margin-left: 25px;
                                width: 40%;
                                border-right: 3px dashed @borderColor;
                                .job-duty{
                                    height: 45px;
                                    line-height: 45px;
                                    font-size: 20px;
                                    color: @fontColor;
                                    .el-link-active();
                                }
                                .job-salary{
                                    font-size: 16px;
                                    color: @salaryColor;
                                }
                            }
                            .apply-status{
                                margin-left: 25px;
                            }
                        }
                    }
                }
            }
        }
        .into-resume{
            .el-page-header{
                height: 80px;
                line-height: 80px;
                background: #f8f9fc;
            }
        }
    }
</style>